package org.example.io;

import java.io.*;

public class DataStream {
    public static void main(String[] args) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);
        dos.writeDouble(Math.random());
        dos.writeBoolean(true);
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        System.out.println(bais.available());
        DataInputStream dis = new DataInputStream(bais);
        System.out.println(dis.readDouble());
        System.out.println(dis.readBoolean());
        dos.close();
        dis.close();

    }
}
